<script type="text/javascript" src="<?php echo JURI::root(); ?>js/dialog/jquery-ui-1.8.20.custom.min.js"></script>
<script type="text/javascript">
    jQuery(function(){

        // Dialog
        jQuery('#dialog').dialog({
            autoOpen: false,
            width: 300,
            height: 200,
            open: function(){
                jQuery("#pick_up_date_obj").val(jQuery("#pick-up-date_"+jQuery("#pick_up_date_member").val()).find("span").html());
                jQuery(this).dialog("open");
            },
            buttons: {
                "Ok": function() {
                    that = this;
                    var queryString = 'id='+jQuery("#pick_up_date_member").val()+"&d="+jQuery("#pick_up_date_obj").val();
                    jQuery.ajax({
                        type: "POST",
                        url: "/administrator/index.php?option=com_wrd&controller=reports&layout=memberservicereport&task=savepickupdate",
                        data: queryString,
                    }).success(function( json ) {
                        var result = eval(json);
                        if(result.success == true) {
                            jQuery("#pick-up-date_"+jQuery("#pick_up_date_member").val()).find("span").html(result.html);
                        }
                        jQuery(that).dialog("close");
                    });
                },
                "Cancel": function() {
                    jQuery(this).dialog("close");
                }
            }
        });

        
        jQuery('.pick-up-date').click(function(){
            var idMember = jQuery(this).attr("name").split("_");
            jQuery("#pick_up_date_member").val(idMember[1]);
            jQuery('#dialog').dialog('open');
            return false;
        });

    });
</script>
<style>
.extra-adminlist strong { color:#025A8D; font-size: 1.2em; font-weight: bold; }
table.extra-adminlist .extra-adminlist-tr td {background: #F7F7F7; }
.filter-detail { border-bottom: 1px solid #CCC; padding-bottom: 3px; font-size: 1.4em; }
.filter-detail span { color: #e72222; }
</style>
<?php 
    $complainType = JHTMLwrd::listComplainTypeRaw();
    $mealPeriod = JHTMLwrd::listMealPeriodRaw();
?>
<script type="text/javascript">
jQuery(function(){
    jQuery("#statistic_by").html(jQuery("#statistic_by").html() + "<span style='color:#000;'>Meal period:</span> " + getSelectedOptionFilter("extra_meal_period")); 
    jQuery("#statistic_by").html(jQuery("#statistic_by").html() + ". <span style='color:#000;'>Outlet:</span> " + getSelectedOptionFilter("pick_up_at"));     
});

function getSelectedOptionFilter(listName)
{
    var html = "";
    jQuery("#"+listName+" option[selected=selected]").each(function(){
        html = html + jQuery(this).html() + ", ";
    });
    return html.substring(0, html.length-2);
}
</script>
<h3><span id="statistic_by"></span><span style="color:#C00; float:right;">Total: <?php echo $this->pagination->total; ?></span></h3>
<table class="adminlist extra-adminlist table">
  <thead>
    <tr class="extra-adminlist-tr" >
        <th nowrap="nowrap"><strong>Member ID</strong></th>        
        <th nowrap="nowrap"><strong>Name</strong></th> 
		<th nowrap="nowrap"><strong>Phone</strong></th> 
        <th nowrap="nowrap"><strong>Created Date</strong></th>
        <th nowrap="nowrap" style="width:10%"><strong>Question</strong></th>
        <th nowrap="nowrap"><strong>Answer</strong></th>
        <th nowrap="nowrap"><strong>Outlet</strong></th>  
        <th nowrap="nowrap"><strong>Type</strong></th> 
        <th nowrap="nowrap"><strong>Pick up Date</strong></th> 
        <th nowrap="nowrap"><strong>Visit Date</strong></th> 
        <th nowrap="nowrap"><strong>Handle By</strong></th>      
    </tr>
  </thead>
  <tbody>
    
    <?php 
        if(!empty($this->items)):
            foreach($this->items as $key => $item):
                echo '<tr class="row'.($key%2).'" valign="top">';
                    echo '<td  style=""><a title="Click to view profile" target="_blank" href="index.php?option=com_wrd&controller=profile&id='.$item->profile_id.'&layout=form">'.$item->vip_number.'</a></td>';   
                    echo '<td style=""><a title="Click to edit this member service" target="_blank" href="index.php?option=com_wrd&controller=mservices&id='.$item->id.'&layout=form">'.$item->l_name.' '.$item->f_name.'</a></td>';   
                    echo '<td   style="">'.$item->phone.'</td>';
					echo '<td   style="">'.$item->created_date.'</td>';
                    echo '<td  style="width:10%">'.$item->questions.'</td>';   
                    echo '<td>'.$item->answer.'</td>';
                    echo '<td  style="">'.$item->outlet.'</td>';   
                    echo '<td  style="">'.$item->member_type.'</td>';
                    
					$pick_up_date = explode(' ', $item->pick_up_date);
                    
                    echo '<td nowrap="nowrap" align="center">'.($pick_up_date[0] != '' ? date('d-m-Y',strtotime($pick_up_date[0])) : '00-00-0000').'</td>';
					echo '<td  style="">'.date('d-m-Y',strtotime($item->visit_date)).'</td>';   
                       
                    echo '<td style="">'.$item->handle_by.'</td>';   
                echo '</tr>';
            endforeach;
        endif;
    ?>
    
  </tbody>
  <tfoot>
        <tr>
            <td colspan="16">
                <?php
                     echo $this->pagination->getListFooter();
                ?>
            </td>
        </tr>
    </tfoot>
</table>